package com.hongxun.modules.eys.service.impl;

import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.hongxun.modules.eys.dao.EPBaseDao;
import com.hongxun.modules.eys.entity.EPBaseEntity;
import com.hongxun.modules.eys.service.EPBaseService;


@Service("ePBaseService")
public class EPBaseServiceImpl implements EPBaseService {
    @Autowired
    private EPBaseDao ePBaseDao;

    @Override
    public EPBaseEntity queryObject(String guid) {
        return ePBaseDao.queryObject(guid);
    }

    @Override
    public List<EPBaseEntity> queryList(Map<String, Object> map) {
        return ePBaseDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return ePBaseDao.queryTotal(map);
    }

    @Override
    public void save(EPBaseEntity ePBase) {
        if (ePBase.getGuid() == null || ePBase.getGuid().equals("")) {

            ePBase.setGuid(UUID.randomUUID().toString());
        }
        ePBaseDao.save(ePBase);
    }

    @Override
    public void update(EPBaseEntity ePBase) {
        ePBaseDao.update(ePBase);
    }

    @Override
    public void delete(String guid) {
        ePBaseDao.delete(guid);
    }

    @Override
    public void deleteBatch(String[] guids) {
        ePBaseDao.deleteBatch(guids);
    }

    @Override
    public void insertOrReplaceOrDelete(EPBaseEntity entities) {
        EPBaseEntity epBaseEntity = ePBaseDao.queryObject(entities.getGuid());
        if (epBaseEntity == null) {
            ePBaseDao.save(entities);
        } else {
            ePBaseDao.update(entities);
        }
    }

}
